﻿using OOAD_PROJEKAT;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Main_application
{
    /// <summary>
    /// Interaction logic for promjena.xaml
    /// </summary>
    public partial class promjena : Window
    {
        Klijent novina;
        public promjena(Klijent kaka)
        {
            InitializeComponent();
            ime.BorderBrush = SystemColors.ControlDarkBrush;
            ime1.BorderBrush = SystemColors.ControlDarkBrush;
            novina = kaka;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(ime.Text))
            {
                ime.BorderBrush = Brushes.Red;
                ime.ToolTip = "Morate izrabrati atribut!";
            }
            else
            {
                ime.BorderBrush = SystemColors.ControlDarkBrush;
                ime.ToolTip = null;
                if (String.IsNullOrEmpty(ime1.Text))
                {
                    ime1.BorderBrush = Brushes.Red;
                    ime1.ToolTip = "Morate unijeti vrijednost!";
                }
                else
                {
                    ime1.BorderBrush = SystemColors.ControlDarkBrush;
                    ime1.ToolTip = null;
                    switch (ime.Text)
                    {
                        case "Ime":
                            novina.Ime = ime1.Text;
                            break;
                        case "Prezime":
                            novina.Prezime = ime1.Text;
                            break;
                        case "JMBG":
                            novina.Jmbg = ime1.Text;
                            break;
                        case "Username":
                            novina.Username = ime1.Text;
                            break;
                        case "Password":
                            novina.Password = ime1.Text;
                            break;
                        case "Status":
                            if (ime1.Text == "Zaposlen")
                                novina.statusKlijenta = SocijalniStatus.Zaposlen;
                            else if (ime1.Text == "Nezaposlen")
                                novina.statusKlijenta = SocijalniStatus.Nezaposlen;
                            else if (ime1.Text == "Student")
                                novina.statusKlijenta = SocijalniStatus.Student;
                            else if (ime1.Text == "Penzioner")
                                novina.statusKlijenta = SocijalniStatus.Penzioner;
                            else novina.statusKlijenta = SocijalniStatus.Nista;
                            break;
                    }
                    try
                    {
                        DAL.DAL.KlijentDAO kl = new DAL.DAL.KlijentDAO();
                        Klijent mm = kl.update(novina);
                        MessageBox.Show(mm.Ime);
                    }
                    catch (Exception la)
                    {
                        MessageBox.Show(la.Message);
                    }
                }
            }
        }
    }
}
